#include "checkError.h"

#include <assert.h>
#include <string>

#include "glad/glad.h"

// 声明且实现错误处理函数
void checkError() {
  GLenum errCode = glGetError();
  // std::cout << "errCode = " << errCode << std::endl;
  std::string err = "";
  switch (errCode) {
  case GL_NO_ERROR:
    // std::cout << "no error" << std::endl;
    break;
  case GL_INVALID_VALUE: {
    err = "invalid value";
  } break;
  case GL_INVALID_ENUM: {
    err = "invalid enum";
  } break;
  case GL_INVALID_OPERATION: {
    err = "invalid operation";
  } break;
  case GL_OUT_OF_MEMORY: {
    err = "out of memory";
  } break;
  default: {
    err = "unknow value";
  } break;
  }
  // std::cout << err << std::endl;
  if (errCode != GL_NO_ERROR) {
    assert(false);
  }
}
